package cn.iocoder.yudao.module.member.alliance.service;

import cn.iocoder.yudao.framework.business.basic.dao.query.CoreQueryWrapper;
import cn.iocoder.yudao.framework.business.basic.pojo.vo.UserSimpleVO;
import cn.iocoder.yudao.framework.business.order.service.AdminOrderBaseService;
import cn.iocoder.yudao.module.api.member.user.MemberUserApi;
import cn.iocoder.yudao.module.member.alliance.dal.dataobject.CloudAllianceOrderDO;
import cn.iocoder.yudao.module.member.alliance.dal.mysql.CloudAllianceOrderMapper;
import cn.iocoder.yudao.module.member.alliance.vo.AdminCloudAllianceOrderQueryDTO;
import cn.iocoder.yudao.module.member.alliance.vo.AdminCloudAllianceOrderVO;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import java.util.Collection;
import java.util.Map;

/**
 * 云盟商身份订单 Service 实现类
 *
 * @author 山野羡民
 */
@Slf4j
@Service
@Validated
public class AdminCloudAllianceOrderServiceImpl extends AdminOrderBaseService<CloudAllianceOrderDO, AdminCloudAllianceOrderVO, AdminCloudAllianceOrderQueryDTO> implements AdminCloudAllianceOrderService {
    @Resource
    private CloudAllianceOrderMapper cloudAllianceOrderMapper;

    @Resource
    private MemberUserApi memberUserApi;

    @Override
    protected CloudAllianceOrderMapper getInjectedMapper() {
        return cloudAllianceOrderMapper;
    }

    @Nonnull
    @Override
    protected CoreQueryWrapper<CloudAllianceOrderDO> buildQueryWrapper(AdminCloudAllianceOrderQueryDTO param) {
        CoreQueryWrapper<CloudAllianceOrderDO> wrapper = super.buildQueryWrapper(param);
        wrapper.eqIfPresent("package_id", param.getPackageId());
        return wrapper;
    }

    @Nonnull
    @Override
    protected Map<Long, UserSimpleVO> getUserSimpleMap(Collection<Long> userIds) {
        return memberUserApi.getUserSimpleMap(userIds);
    }

}